<template>
  <div class="max-w-4xl mx-auto">
    <Transition name="fade" mode="out-in">
      <div v-if="stage === 'instructions'" key="instructions">
        <Card class="bg-white/90 backdrop-blur-sm border-violet-200 shadow-lg">
          <CardHeader class="text-center pb-8">
            <div
              class="w-16 h-16 bg-gradient-to-br from-violet-600 to-purple-500 rounded-2xl flex items-center justify-center mx-auto mb-4 shadow-lg"
            >
              <Scale class="w-8 h-8 text-white" />
            </div>
            <CardTitle class="text-2xl text-slate-800">{{
              $t("decisionMakingTest.title")
            }}</CardTitle>
            <p class="text-slate-600 mt-2">
              {{ $t("decisionMakingTest.description") }}
            </p>
          </CardHeader>

          <CardContent class="space-y-6">
            <div
              class="bg-gradient-to-r from-violet-50 to-purple-50 rounded-xl p-6 border border-violet-100"
            >
              <h3
                class="font-semibold text-violet-900 mb-4 flex items-center gap-2"
              >
                <Star class="w-5 h-5" />
                {{ $t("decisionMakingTest.instructionsTitle") }}
              </h3>
              <div class="space-y-3 text-slate-700">
                <div class="flex gap-3">
                  <span
                    class="w-6 h-6 bg-violet-600 text-white rounded-full flex items-center justify-center text-sm font-semibold flex-shrink-0 mt-0.5"
                    >1</span
                  >
                  <p>{{ $t("decisionMakingTest.instruction1") }}</p>
                </div>
                <div class="flex gap-3">
                  <span
                    class="w-6 h-6 bg-violet-600 text-white rounded-full flex items-center justify-center text-sm font-semibold flex-shrink-0 mt-0.5"
                    >2</span
                  >
                  <p>{{ $t("decisionMakingTest.instruction2") }}</p>
                </div>
                <div class="flex gap-3">
                  <span
                    class="w-6 h-6 bg-violet-600 text-white rounded-full flex items-center justify-center text-sm font-semibold flex-shrink-0 mt-0.5"
                    >3</span
                  >
                  <p>{{ $t("decisionMakingTest.instruction3") }}</p>
                </div>
                <div class="flex gap-3">
                  <span
                    class="w-6 h-6 bg-violet-600 text-white rounded-full flex items-center justify-center text-sm font-semibold flex-shrink-0 mt-0.5"
                    >4</span
                  >
                  <p>{{ $t("decisionMakingTest.instruction4") }}</p>
                </div>
                <div class="flex gap-3">
                  <span
                    class="w-6 h-6 bg-violet-600 text-white rounded-full flex items-center justify-center text-sm font-semibold flex-shrink-0 mt-0.5"
                    >5</span
                  >
                  <p>{{ $t("decisionMakingTest.instruction5") }}</p>
                </div>
              </div>
            </div>

            <div class="grid grid-cols-2 gap-4">
              <div
                class="bg-gradient-to-br from-blue-50 to-blue-100 rounded-xl p-4 border border-blue-200"
              >
                <h4
                  class="font-semibold text-blue-800 mb-2 flex items-center gap-2"
                >
                  <TrendingUp class="w-4 h-4" />
                  {{ $t("decisionMakingTest.type.probability") }}
                </h4>
                <p class="text-sm text-blue-700">
                  {{ $t("decisionMakingTest.type.probabilityDesc") }}
                </p>
              </div>
              <div
                class="bg-gradient-to-br from-red-50 to-red-100 rounded-xl p-4 border border-red-200"
              >
                <h4
                  class="font-semibold text-red-800 mb-2 flex items-center gap-2"
                >
                  <AlertTriangle class="w-4 h-4" />
                  {{ $t("decisionMakingTest.type.risk") }}
                </h4>
                <p class="text-sm text-red-700">
                  {{ $t("decisionMakingTest.type.riskDesc") }}
                </p>
              </div>
              <div
                class="bg-gradient-to-br from-green-50 to-green-100 rounded-xl p-4 border border-green-200"
              >
                <h4
                  class="font-semibold text-green-800 mb-2 flex items-center gap-2"
                >
                  <Scale class="w-4 h-4" />
                  {{ $t("decisionMakingTest.type.multi-criteria") }}
                </h4>
                <p class="text-sm text-green-700">
                  {{ $t("decisionMakingTest.type.multi-criteriaDesc") }}
                </p>
              </div>
              <div
                class="bg-gradient-to-br from-orange-50 to-orange-100 rounded-xl p-4 border border-orange-200"
              >
                <h4
                  class="font-semibold text-orange-800 mb-2 flex items-center gap-2"
                >
                  <Clock class="w-4 h-4" />
                  {{ $t("decisionMakingTest.type.temporal") }}
                </h4>
                <p class="text-sm text-orange-700">
                  {{ $t("decisionMakingTest.type.temporalDesc") }}
                </p>
              </div>
              <div
                class="bg-gradient-to-br from-purple-50 to-purple-100 rounded-xl p-4 border border-purple-200"
              >
                <h4
                  class="font-semibold text-purple-800 mb-2 flex items-center gap-2"
                >
                  <Lightbulb class="w-4 h-4" />
                  {{ $t("decisionMakingTest.type.ethical") }}
                </h4>
                <p class="text-sm text-purple-700">
                  {{ $t("decisionMakingTest.type.ethicalDesc") }}
                </p>
              </div>
              <div
                class="bg-gradient-to-br from-indigo-50 to-indigo-100 rounded-xl p-4 border border-indigo-200"
              >
                <h4
                  class="font-semibold text-indigo-800 mb-2 flex items-center gap-2"
                >
                  <Trophy class="w-4 h-4" />
                  {{ $t("decisionMakingTest.type.strategic") }}
                </h4>
                <p class="text-sm text-indigo-700">
                  {{ $t("decisionMakingTest.type.strategicDesc") }}
                </p>
              </div>
            </div>

            <div class="grid md:grid-cols-3 gap-4">
              <div
                class="text-center p-4 bg-gradient-to-br from-violet-50 to-violet-100 rounded-xl border border-violet-200"
              >
                <div class="text-2xl font-bold text-violet-600 mb-1">50+</div>
                <div class="text-sm text-violet-700">
                  {{ $t("decisionMakingTest.questionBankSize") }}
                </div>
              </div>
              <div
                class="text-center p-4 bg-gradient-to-br from-purple-50 to-purple-100 rounded-xl border border-purple-200"
              >
                <div class="text-2xl font-bold text-purple-600 mb-1">6</div>
                <div class="text-sm text-purple-700">
                  {{ $t("decisionMakingTest.decisionTypes") }}
                </div>
              </div>
              <div
                class="text-center p-4 bg-gradient-to-br from-violet-50 to-purple-50 rounded-xl border border-violet-200"
              >
                <div class="text-2xl font-bold text-slate-600 mb-1">12</div>
                <div class="text-sm text-slate-700">
                  {{ $t("decisionMakingTest.minuteTimeLimit") }}
                </div>
              </div>
            </div>

            <Button
              @click="handleStartTest"
              class="w-full bg-gradient-to-r from-violet-600 to-purple-500 hover:from-violet-700 hover:to-purple-600 text-white py-3 text-lg font-semibold shadow-lg hover:shadow-xl transition-all duration-200"
              size="lg"
            >
              {{ $t("decisionMakingTest.startButton") }}
            </Button>
          </CardContent>
        </Card>
      </div>

      <div
        v-else-if="stage === 'test' && decision"
        key="test"
        class="space-y-6"
      >
        <div
          class="flex flex-col sm:flex-row gap-4 items-center justify-between"
        >
          <div class="flex items-center gap-4">
            <Badge
              variant="outline"
              class="bg-violet-100 text-violet-700 border-violet-300"
            >
              {{ $t("decisionMakingTest.decisionProgress") }}
              {{ currentDecisionIndex + 1 }} /
              {{ selectedDecisions.length }}
            </Badge>
            <Badge variant="outline" :class="decisionTypeBadgeClass">
              {{ decisionTypeName }}
            </Badge>
            <Badge variant="outline" :class="difficultyBadgeClass">
              {{ difficultyName }}
            </Badge>
            <div class="flex items-center gap-2 text-slate-600">
              <Trophy class="w-4 h-4" />
              <span class="font-semibold">{{ score }}</span>
            </div>
          </div>

          <div class="flex items-center gap-4">
            <div class="text-center">
              <div
                :class="[
                  'text-2xl font-bold font-mono',
                  decisionTimeLeft <= 10 ? 'text-red-500' : 'text-violet-700',
                ]"
              >
                {{ decisionTimeLeft }}
              </div>
              <div class="text-xs text-slate-500">
                {{ $t("decisionMakingTest.decisionTime") }}
              </div>
            </div>
            <div class="text-center">
              <div class="text-lg font-mono text-slate-600">
                {{ Math.floor(timeLeft / 60) }}:{{
                  (timeLeft % 60).toString().padStart(2, "0")
                }}
              </div>
              <div class="text-xs text-slate-500">
                {{ $t("decisionMakingTest.totalRemaining") }}
              </div>
            </div>
          </div>
        </div>

        <Progress :model-value="progress" class="h-2" />

        <Card
          class="bg-white/90 backdrop-blur-sm border-violet-200 shadow-lg relative"
        >
          <CardHeader>
            <CardTitle class="text-xl text-slate-800">{{
              decision.scenario
            }}</CardTitle>
          </CardHeader>
          <CardContent class="space-y-4">
            <Transition name="fade-slide" mode="out-in">
              <div v-if="!feedback.show && awaitingResponse" class="space-y-3">
                <button
                  v-for="option in decision.options"
                  :key="option.id"
                  @click="handleDecisionSelect(option.id)"
                  class="w-full h-auto min-h-[4rem] text-left justify-start p-4 border rounded-lg hover:bg-violet-50 hover:border-violet-300 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-violet-400"
                >
                  <div class="flex items-start gap-3">
                    <span
                      class="w-8 h-8 bg-violet-100 text-violet-700 rounded-full flex items-center justify-center text-sm font-semibold flex-shrink-0 mt-1"
                    >
                      {{ String.fromCharCode(65 + option.id) }}
                    </span>
                    <div class="text-left">
                      <p class="text-slate-800">{{ option.description }}</p>
                      <p
                        v-if="option.probability"
                        class="text-xs text-slate-500 mt-1"
                      >
                        {{ $t("decisionMakingTest.successProbability") }}
                        {{ Math.round(option.probability * 100) }}%
                      </p>
                    </div>
                  </div>
                </button>
              </div>
              <div v-else-if="feedback.show" class="space-y-4">
                <div
                  :class="[
                    'p-6 rounded-xl border-2',
                    feedback.correct
                      ? 'bg-green-50 border-green-200'
                      : 'bg-orange-50 border-orange-200',
                  ]"
                >
                  <div class="flex items-center gap-3 mb-4">
                    <div
                      :class="[
                        'w-12 h-12 rounded-full flex items-center justify-center',
                        feedback.correct ? 'bg-green-500' : 'bg-orange-500',
                      ]"
                    >
                      <CheckCircle
                        v-if="feedback.correct"
                        class="w-6 h-6 text-white"
                      />
                      <XCircle v-else class="w-6 h-6 text-white" />
                    </div>
                    <div>
                      <h3
                        :class="[
                          'text-lg font-semibold',
                          feedback.correct
                            ? 'text-green-800'
                            : 'text-orange-800',
                        ]"
                      >
                        {{
                          feedback.correct
                            ? $t("decisionMakingTest.optimalDecision")
                            : $t("decisionMakingTest.couldBeBetter")
                        }}
                      </h3>
                      <p class="text-sm text-slate-600">
                        {{ $t("decisionMakingTest.reactionTime") }}
                        {{ Math.round(feedback.reactionTime / 10) / 100 }}
                        {{ $t("decisionMakingTest.seconds") }}
                      </p>
                    </div>
                  </div>

                  <div class="mb-3">
                    <span class="text-sm font-medium text-slate-600">{{
                      $t("decisionMakingTest.yourChoice")
                    }}</span>
                    <p class="text-slate-800 mt-1">
                      {{ feedback.selectedOption }}
                    </p>
                  </div>

                  <div v-if="!feedback.correct" class="mb-3">
                    <span class="text-sm font-medium text-slate-600">{{
                      $t("decisionMakingTest.recommendedChoice")
                    }}</span>
                    <p class="text-slate-800 mt-1">
                      {{ feedback.correctOption }}
                    </p>
                  </div>

                  <div v-if="feedback.explanation" class="flex gap-3">
                    <Lightbulb
                      class="w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5"
                    />
                    <div>
                      <span class="text-sm font-medium text-slate-600">{{
                        $t("decisionMakingTest.explanation")
                      }}</span>
                      <p class="text-slate-700 mt-1">
                        {{ feedback.explanation }}
                      </p>
                    </div>
                  </div>
                </div>

                <Transition name="fade-up">
                  <div v-if="showContinueButton" class="text-center">
                    <Button
                      @click="handleContinue"
                      class="bg-gradient-to-r from-violet-600 to-purple-500 hover:from-violet-700 hover:to-purple-600 text-white px-8 py-3 font-semibold shadow-lg hover:shadow-xl transition-all duration-200"
                    >
                      <template
                        v-if="
                          currentDecisionIndex < selectedDecisions.length - 1
                        "
                      >
                        {{ $t("decisionMakingTest.nextQuestion") }}
                        <ArrowRight class="w-4 h-4 ml-2" />
                      </template>
                      <template v-else>
                        {{ $t("decisionMakingTest.viewResults") }}
                        <Play class="w-4 h-4 ml-2" />
                      </template>
                    </Button>
                  </div>
                </Transition>
              </div>
            </Transition>
          </CardContent>
        </Card>
      </div>

      <div v-else-if="stage === 'results'" key="results">
        <Card class="bg-white/90 backdrop-blur-sm border-violet-200 shadow-xl">
          <CardHeader class="text-center pb-6">
            <div
              class="w-20 h-20 bg-gradient-to-br from-violet-600 to-purple-500 rounded-2xl flex items-center justify-center mx-auto mb-4 shadow-lg"
            >
              <Trophy class="w-10 h-10 text-white" />
            </div>

            <CardTitle class="text-3xl text-slate-800 mb-2">{{
              $t("decisionMakingTest.testComplete")
            }}</CardTitle>
            <div
              class="text-6xl font-bold bg-gradient-to-r from-violet-600 to-purple-500 bg-clip-text text-transparent"
            >
              {{ finalResult.score }}
            </div>
            <p class="text-slate-600">
              {{ $t("decisionMakingTest.scoreTitle") }}
            </p>
          </CardHeader>

          <CardContent class="space-y-6">
            <div class="grid grid-cols-2 gap-4">
              <div
                class="text-center p-4 bg-gradient-to-br from-violet-50 to-violet-100 rounded-xl border border-violet-200"
              >
                <div class="text-2xl font-bold text-violet-600 mb-1">
                  {{ finalResult.details.correctDecisions }}/{{
                    finalResult.details.totalDecisions
                  }}
                </div>
                <div class="text-sm text-violet-700">
                  {{ $t("decisionMakingTest.optimalDecisions") }}
                </div>
              </div>
              <div
                class="text-center p-4 bg-gradient-to-br from-purple-50 to-purple-100 rounded-xl border border-purple-200"
              >
                <div class="text-2xl font-bold text-purple-600 mb-1">
                  {{ finalResult.details.avgDecisionTime }}s
                </div>
                <div class="text-sm text-purple-700">
                  {{ $t("decisionMakingTest.avgDecisionTime") }}
                </div>
              </div>
            </div>

            <div class="space-y-3">
              <div
                class="flex justify-between items-center p-3 bg-slate-50 rounded-lg"
              >
                <span class="text-slate-600">{{
                  $t("decisionMakingTest.decisionAccuracy")
                }}</span>
                <span class="font-semibold text-slate-800"
                  >{{ finalResult.details.accuracy }}%</span
                >
              </div>
              <div
                class="flex justify-between items-center p-3 bg-slate-50 rounded-lg"
              >
                <span class="text-slate-600">{{
                  $t("decisionMakingTest.decisionQualityIndex")
                }}</span>
                <span class="font-semibold text-slate-800">{{
                  finalResult.details.decisionQualityIndex
                }}</span>
              </div>
              <div
                class="flex justify-between items-center p-3 bg-slate-50 rounded-lg"
              >
                <span class="text-slate-600">{{
                  $t("decisionMakingTest.totalScore")
                }}</span>
                <span class="font-semibold text-slate-800"
                  >{{ finalResult.details.totalScore }}/{{
                    finalResult.details.maxPossibleScore
                  }}</span
                >
              </div>
              <div
                class="flex justify-between items-center p-3 bg-slate-50 rounded-lg"
              >
                <span class="text-slate-600">{{
                  $t("decisionMakingTest.decisionConsistency")
                }}</span>
                <span class="font-semibold text-slate-800"
                  >{{ finalResult.details.consistencyIndex }}%</span
                >
              </div>
            </div>

            <div
              class="bg-gradient-to-r from-violet-50 to-purple-50 rounded-xl p-4 border border-violet-100"
            >
              <h3
                class="font-semibold text-violet-900 mb-3 flex items-center gap-2"
              >
                <Scale class="w-5 h-5" />
                {{ $t("decisionMakingTest.questionComposition") }}
              </h3>
              <div class="space-y-2 text-sm">
                <div class="flex justify-between">
                  <span class="text-slate-600">{{
                    $t("decisionMakingTest.randomlySelectedQuestions")
                  }}</span>
                  <span class="text-violet-600"
                    >{{ finalResult.details.totalDecisions
                    }}{{ $t("decisionMakingTest.questionUnit") }}</span
                  >
                </div>
                <div class="flex justify-between">
                  <span class="text-slate-600">{{
                    $t("decisionMakingTest.totalQuestionBankSize")
                  }}</span>
                  <span class="text-purple-600"
                    >{{ DECISION_POOL.length
                    }}{{ $t("decisionMakingTest.questionUnit") }}</span
                  >
                </div>
                <div class="flex justify-between">
                  <span class="text-slate-600">{{
                    $t("decisionMakingTest.questionTypeCoverage")
                  }}</span>
                  <span class="text-slate-600"
                    >{{ new Set(selectedDecisions.map((d) => d.type)).size
                    }}{{ $t("decisionMakingTest.typeUnit") }}</span
                  >
                </div>
              </div>
            </div>

            <Button
              @click="emit('complete', finalResult)"
              class="w-full bg-gradient-to-r from-violet-600 to-purple-500 hover:from-violet-700 hover:to-purple-600 text-white py-3 text-lg font-semibold shadow-lg hover:shadow-xl transition-all duration-200"
              size="lg"
            >
              {{ $t("decisionMakingTest.completeAndReturn") }}
            </Button>
          </CardContent>
        </Card>
      </div>
      <div v-else class="text-center p-8">
        <p class="text-slate-600">{{ $t("decisionMakingTest.loadingTest") }}</p>
      </div>
    </Transition>
  </div>
</template>

<script setup>
import { ref, computed, onUnmounted, watch } from "vue";
import {
  Scale,
  Clock,
  Trophy,
  Star,
  TrendingUp,
  AlertTriangle,
  CheckCircle,
  XCircle,
  Lightbulb,
  ArrowRight,
  Play,
} from "lucide-vue-next";

const emit = defineEmits(["complete"]);

const DECISION_POOL = [
  // ... (The full array of 50 decisions is included here)
  // Investment
  {
    id: 1,
    type: "probability",
    scenario: "投资选择：您有10万元可以投资，需要选择最优策略",
    options: [
      {
        id: 0,
        description: "银行存款：年收益3%，几乎无风险",
        probability: 0.95,
        reward: 3000,
        value: 75,
      },
      {
        id: 1,
        description: "股票投资：可能收益15%，也可能亏损10%",
        probability: 0.6,
        reward: 15000,
        value: 80,
      },
      {
        id: 2,
        description: "基金投资：预期收益8%，风险适中",
        probability: 0.8,
        reward: 8000,
        value: 85,
      },
      {
        id: 3,
        description: "创业投资：可能翻倍，也可能全亏",
        probability: 0.3,
        reward: 100000,
        value: 60,
      },
    ],
    correctChoice: 2,
    explanation:
      "基金投资在风险和收益之间取得了最佳平衡，具有良好的风险收益比，适合大多数投资者的风险偏好",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 2,
    type: "risk",
    scenario: "医疗决策：您需要选择治疗方案",
    options: [
      {
        id: 0,
        description: "保守治疗：成功率80%，恢复时间长",
        probability: 0.8,
        value: 70,
      },
      {
        id: 1,
        description: "手术治疗：成功率95%，但有5%严重并发症风险",
        probability: 0.95,
        value: 85,
      },
      {
        id: 2,
        description: "新药治疗：成功率85%，副作用轻微",
        probability: 0.85,
        value: 80,
      },
      {
        id: 3,
        description: "等待观察：无风险，但可能病情恶化",
        probability: 0.6,
        value: 40,
      },
    ],
    correctChoice: 1,
    explanation:
      "尽管有风险，但手术治疗的成功率最高，整体效益最大化，在医疗决策中应优先考虑治疗效果",
    timeLimit: 60,
    difficulty: "hard",
  },
  {
    id: 3,
    type: "multi-criteria",
    scenario: "工作选择：您需要在多个offer中选择",
    options: [
      { id: 0, description: "大公司：薪资高，但工作压力大，晋升慢", value: 75 },
      {
        id: 1,
        description: "初创公司：薪资中等，股权激励，风险较高",
        value: 70,
      },
      {
        id: 2,
        description: "外企：薪资很高，工作环境好，但发展空间有限",
        value: 80,
      },
      { id: 3, description: "国企：稳定，福利好，但创新机会少", value: 65 },
    ],
    correctChoice: 2,
    explanation:
      "外企在综合考虑薪资、环境、稳定性等因素后性价比最高，能够平衡短期收益和工作质量",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 4,
    type: "temporal",
    scenario: "学习规划：距离考试还有3个月，如何分配时间？",
    options: [
      { id: 0, description: "平均分配：每科每天1小时，稳扎稳打", value: 75 },
      { id: 1, description: "重点突破：集中精力攻克薄弱科目", value: 85 },
      { id: 2, description: "强化优势：在已有优势基础上提升", value: 60 },
      { id: 3, description: "临时抱佛脚：前期轻松，最后一个月冲刺", value: 40 },
    ],
    correctChoice: 1,
    explanation:
      "重点突破薄弱环节能够最大化整体提升效果，符合边际效用递减规律，是最优的时间分配策略",
    timeLimit: 40,
    difficulty: "easy",
  },
  {
    id: 5,
    type: "probability",
    scenario: "保险购买：评估以下保险方案的性价比",
    options: [
      {
        id: 0,
        description: "基础保险：保费低，保障基本",
        probability: 0.9,
        value: 70,
      },
      {
        id: 1,
        description: "全面保险：保费高，保障全面",
        probability: 0.95,
        value: 80,
      },
      {
        id: 2,
        description: "专项保险：针对特定风险，性价比高",
        probability: 0.85,
        value: 85,
      },
      {
        id: 3,
        description: "不买保险：省钱，但承担全部风险",
        probability: 0.1,
        value: 30,
      },
    ],
    correctChoice: 2,
    explanation:
      "专项保险在成本和保障之间达到最佳平衡，针对性强且性价比高，避免过度保险和保险不足",
    timeLimit: 35,
    difficulty: "medium",
  },
  {
    id: 6,
    type: "strategic",
    scenario: "创业决策：您的初创项目面临资金短缺",
    options: [
      {
        id: 0,
        description: "寻找投资：可能稀释股权，但获得资金和资源",
        value: 80,
      },
      { id: 1, description: "银行贷款：利息负担重，但保持控制权", value: 65 },
      { id: 2, description: "暂停项目：保存实力，等待更好时机", value: 50 },
      { id: 3, description: "个人借贷：快速但风险极高", value: 35 },
    ],
    correctChoice: 0,
    explanation:
      "寻找投资能带来资金和战略资源，长期价值最高，是创业公司快速发展的最优策略",
    timeLimit: 55,
    difficulty: "hard",
  },
  {
    id: 7,
    type: "multi-criteria",
    scenario: "购房决策：在预算范围内选择最适合的房产",
    options: [
      {
        id: 0,
        description: "市中心小户型：地段好，升值潜力大，但空间小",
        value: 75,
      },
      {
        id: 1,
        description: "郊区大户型：空间大，环境好，但通勤不便",
        value: 70,
      },
      { id: 2, description: "学区房：教育资源好，但房龄较老", value: 80 },
      { id: 3, description: "新开发区：价格便宜，但配套不完善", value: 60 },
    ],
    correctChoice: 2,
    explanation:
      "学区房在长期价值和实用性方面具有优势，教育投资回报率高，保值增值能力强",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 8,
    type: "temporal",
    scenario: "退休规划：40岁的您需要为退休做准备",
    options: [
      { id: 0, description: "激进投资：高风险高回报，时间充裕", value: 70 },
      { id: 1, description: "稳健配置：风险适中，收益稳定", value: 85 },
      { id: 2, description: "保守储蓄：风险极低，但收益有限", value: 60 },
      { id: 3, description: "暂不考虑：享受当下，未来再说", value: 20 },
    ],
    correctChoice: 1,
    explanation:
      "40岁适合稳健配置，平衡风险和收益，时间分散风险策略最优，为退休做好充分准备",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 9,
    type: "probability",
    scenario: "新产品发布：市场推广策略选择",
    options: [
      {
        id: 0,
        description: "大规模营销：高投入，快速占领市场",
        probability: 0.7,
        value: 75,
      },
      {
        id: 1,
        description: "精准营销：成本适中，针对目标用户",
        probability: 0.85,
        value: 85,
      },
      {
        id: 2,
        description: "口碑营销：成本低，但传播速度慢",
        probability: 0.6,
        value: 65,
      },
      {
        id: 3,
        description: "不做推广：依靠产品本身",
        probability: 0.3,
        value: 40,
      },
    ],
    correctChoice: 1,
    explanation:
      "精准营销具有最佳的成功概率和投入产出比，能够有效触达目标用户群体，是最理性的选择",
    timeLimit: 40,
    difficulty: "medium",
  },
  {
    id: 10,
    type: "risk",
    scenario: "股票投资：市场波动中的投资策略",
    options: [
      { id: 0, description: "全仓买入：抓住机会，但风险极高", value: 50 },
      { id: 1, description: "分批建仓：降低风险，平摊成本", value: 85 },
      { id: 2, description: "观望等待：保守策略，可能错过机会", value: 60 },
      { id: 3, description: "借钱加杠杆：放大收益，风险翻倍", value: 30 },
    ],
    correctChoice: 1,
    explanation:
      "分批建仓是风险管理的最佳实践，能有效平摊成本和降低风险，是专业投资者的首选策略",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 11,
    type: "strategic",
    scenario: "职业转型：您在传统行业工作5年，考虑转入AI领域",
    options: [
      { id: 0, description: "直接跳槽：风险高，但机会大", value: 70 },
      { id: 1, description: "先学习再转：稳妥但时间成本高", value: 85 },
      { id: 2, description: "内部转岗：安全但机会有限", value: 65 },
      { id: 3, description: "保持现状：稳定但可能错过机会", value: 40 },
    ],
    correctChoice: 1,
    explanation:
      "先学习再转型是最稳妥的策略，能够降低转型风险并提高成功概率，时间投资换取长期价值",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 12,
    type: "multi-criteria",
    scenario: "团队管理：如何处理团队内部的意见分歧",
    options: [
      { id: 0, description: "民主投票：公平但可能效率低", value: 75 },
      { id: 1, description: "专家意见：权威但可能忽视其他观点", value: 70 },
      { id: 2, description: "综合讨论：全面但耗时较长", value: 85 },
      { id: 3, description: "领导决定：快速但可能缺乏认同", value: 60 },
    ],
    correctChoice: 2,
    explanation:
      "综合讨论能够集思广益，提高决策质量和团队认同度，是最佳的团队决策方式",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 13,
    type: "temporal",
    scenario: "健康管理：30岁的您需要制定健康计划",
    options: [
      { id: 0, description: "高强度锻炼：快速见效，但难以坚持", value: 60 },
      { id: 1, description: "适度运动：循序渐进，容易养成习惯", value: 85 },
      { id: 2, description: "偶尔运动：压力小，但效果有限", value: 50 },
      { id: 3, description: "暂不运动：省时省力，但健康风险大", value: 20 },
    ],
    correctChoice: 1,
    explanation:
      "适度运动是最可持续的健康策略，既能保证效果又容易坚持，符合行为经济学原理",
    timeLimit: 35,
    difficulty: "easy",
  },
  {
    id: 14,
    type: "probability",
    scenario: "旅行计划：选择度假目的地",
    options: [
      {
        id: 0,
        description: "热门景点：设施完善，但人多价高",
        probability: 0.9,
        value: 70,
      },
      {
        id: 1,
        description: "小众目的地：独特体验，但风险较高",
        probability: 0.6,
        value: 75,
      },
      {
        id: 2,
        description: "周边游：方便安全，性价比高",
        probability: 0.95,
        value: 85,
      },
      {
        id: 3,
        description: "冒险旅行：刺激但风险极高",
        probability: 0.4,
        value: 50,
      },
    ],
    correctChoice: 2,
    explanation:
      "周边游在安全性、性价比和便利性方面都有优势，是最理性的旅行选择",
    timeLimit: 40,
    difficulty: "easy",
  },
  {
    id: 15,
    type: "strategic",
    scenario: "市场竞争：面对强大竞争对手的策略",
    options: [
      { id: 0, description: "正面竞争：直接对抗，拼实力", value: 60 },
      { id: 1, description: "差异化竞争：避开锋芒，找细分市场", value: 85 },
      { id: 2, description: "价格战：降低利润，抢夺市场", value: 50 },
      { id: 3, description: "合作共赢：化敌为友，共同发展", value: 80 },
    ],
    correctChoice: 1,
    explanation:
      "差异化竞争是弱者战胜强者的最佳策略，通过细分市场找到自己的优势领域",
    timeLimit: 50,
    difficulty: "hard",
  },
  {
    id: 16,
    type: "risk",
    scenario: "产品研发：新技术投入决策",
    options: [
      { id: 0, description: "大量投入：抢占先机，但风险很高", value: 70 },
      { id: 1, description: "分阶段投入：控制风险，稳步推进", value: 85 },
      { id: 2, description: "等待观望：安全但可能落后", value: 50 },
      { id: 3, description: "跟随策略：降低风险，但错失先机", value: 65 },
    ],
    correctChoice: 1,
    explanation: "分阶段投入是创新项目的最佳策略，既能控制风险又能保持竞争力",
    timeLimit: 55,
    difficulty: "hard",
  },
  {
    id: 17,
    type: "temporal",
    scenario: "子女教育：选择教育路径",
    options: [
      { id: 0, description: "公立学校：成本低，质量稳定", value: 75 },
      { id: 1, description: "私立学校：个性化教育，但费用高", value: 80 },
      { id: 2, description: "国际学校：国际化视野，适应性强", value: 85 },
      { id: 3, description: "在家教育：完全个性化，但社交不足", value: 60 },
    ],
    correctChoice: 2,
    explanation:
      "国际学校能够提供国际化视野和适应性培养，在全球化时代具有长远优势",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 18,
    type: "multi-criteria",
    scenario: "技能学习：选择最有价值的技能",
    options: [
      { id: 0, description: "编程技能：需求大，但竞争激烈", value: 80 },
      { id: 1, description: "语言能力：通用性强，持续价值高", value: 85 },
      { id: 2, description: "专业技术：深度专精，但适用面窄", value: 70 },
      { id: 3, description: "软技能：应用广泛，难以量化", value: 75 },
    ],
    correctChoice: 1,
    explanation: "语言能力具有最强的通用性和持续价值，是最值得投资的技能",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 19,
    type: "ethical",
    scenario: "环保选择：个人环保行为的取舍",
    options: [
      { id: 0, description: "极简生活：环保效果好，但生活质量下降", value: 70 },
      { id: 1, description: "绿色消费：平衡环保和生活质量", value: 85 },
      { id: 2, description: "技术环保：依靠科技解决环保问题", value: 80 },
      { id: 3, description: "维持现状：个人行为影响有限", value: 30 },
    ],
    correctChoice: 1,
    explanation:
      "绿色消费能够在环保和生活质量之间找到平衡，是最可持续的环保方式",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 20,
    type: "ethical",
    scenario: "数据隐私：平衡便利性和隐私保护",
    options: [
      { id: 0, description: "完全保护：最大化隐私，但失去便利", value: 70 },
      { id: 1, description: "选择性分享：平衡隐私和便利", value: 85 },
      { id: 2, description: "信任平台：依赖平台自律", value: 60 },
      { id: 3, description: "无所谓：便利优先，忽视隐私", value: 40 },
    ],
    correctChoice: 1,
    explanation: "选择性分享是最理性的隐私策略，既能享受便利又能保护核心隐私",
    timeLimit: 40,
    difficulty: "medium",
  },
  {
    id: 21,
    type: "strategic",
    scenario: "危机管理：公司面临公关危机的处理策略",
    options: [
      { id: 0, description: "立即道歉：快速反应，但可能承认责任", value: 70 },
      { id: 1, description: "调查后回应：负责任但可能延误时机", value: 85 },
      { id: 2, description: "转移注意力：减少关注，但可能适得其反", value: 50 },
      { id: 3, description: "保持沉默：避免错误，但可能被质疑", value: 40 },
    ],
    correctChoice: 1,
    explanation:
      "调查后回应体现了负责任的态度，既能保证信息准确性又能维护公司形象",
    timeLimit: 60,
    difficulty: "hard",
  },
  {
    id: 22,
    type: "probability",
    scenario: "天气决策：户外活动遇到50%降雨概率",
    options: [
      {
        id: 0,
        description: "如期进行：享受活动，但可能淋雨",
        probability: 0.5,
        value: 70,
      },
      {
        id: 1,
        description: "改为室内：安全但体验不同",
        probability: 0.9,
        value: 75,
      },
      {
        id: 2,
        description: "延期举行：等待好天气",
        probability: 0.8,
        value: 85,
      },
      {
        id: 3,
        description: "取消活动：避免风险，但失去机会",
        probability: 1,
        value: 40,
      },
    ],
    correctChoice: 2,
    explanation: "延期举行是最理性的选择，既能确保活动质量又能避免天气风险",
    timeLimit: 30,
    difficulty: "easy",
  },
  {
    id: 23,
    type: "multi-criteria",
    scenario: "时间管理：工作日程安排优化",
    options: [
      { id: 0, description: "严格计划：效率高但缺乏灵活性", value: 75 },
      { id: 1, description: "灵活安排：适应性强，效率稍低", value: 80 },
      { id: 2, description: "优先级管理：重要事项优先", value: 85 },
      { id: 3, description: "随性而为：自由但可能混乱", value: 50 },
    ],
    correctChoice: 2,
    explanation:
      "优先级管理是最有效的时间管理方法，能够确保重要事项得到充分关注",
    timeLimit: 35,
    difficulty: "easy",
  },
  {
    id: 24,
    type: "risk",
    scenario: "创新项目：是否投资未经验证的新技术",
    options: [
      { id: 0, description: "大胆投资：抢占先机，但风险极高", value: 65 },
      { id: 1, description: "小规模试点：控制风险，验证可行性", value: 85 },
      { id: 2, description: "等待验证：安全但可能错失机会", value: 60 },
      { id: 3, description: "完全拒绝：零风险但无收益", value: 30 },
    ],
    correctChoice: 1,
    explanation:
      "小规模试点是创新投资的最佳策略，既能验证技术可行性又能控制投资风险",
    timeLimit: 50,
    difficulty: "hard",
  },
  {
    id: 25,
    type: "temporal",
    scenario: "储蓄计划：如何分配月收入",
    options: [
      { id: 0, description: "激进储蓄：储蓄50%，生活质量下降", value: 70 },
      { id: 1, description: "平衡储蓄：储蓄20-30%，生活储蓄并重", value: 85 },
      { id: 2, description: "保守储蓄：储蓄10%，享受当下", value: 65 },
      { id: 3, description: "无储蓄：花光收入，及时行乐", value: 30 },
    ],
    correctChoice: 1,
    explanation: "平衡储蓄策略能够在当前生活质量和未来安全之间取得最佳平衡",
    timeLimit: 40,
    difficulty: "medium",
  },
  {
    id: 26,
    type: "strategic",
    scenario: "人际关系：如何处理工作中的人际冲突",
    options: [
      { id: 0, description: "直接对话：坦诚沟通，但可能激化矛盾", value: 75 },
      { id: 1, description: "寻求调解：第三方介入，客观公正", value: 85 },
      { id: 2, description: "避免冲突：暂时回避，但问题未解决", value: 50 },
      { id: 3, description: "上级汇报：寻求权威，但可能损害关系", value: 60 },
    ],
    correctChoice: 1,
    explanation: "寻求调解是处理人际冲突的最佳方式，既能解决问题又能维护关系",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 27,
    type: "probability",
    scenario: "购物决策：限时促销的购买选择",
    options: [
      {
        id: 0,
        description: "立即购买：抓住优惠，但可能冲动消费",
        probability: 0.7,
        value: 70,
      },
      {
        id: 1,
        description: "理性评估：考虑需求再决定",
        probability: 0.9,
        value: 85,
      },
      {
        id: 2,
        description: "等下次促销：错过优惠，但避免冲动",
        probability: 0.6,
        value: 75,
      },
      {
        id: 3,
        description: "放弃购买：节省金钱，但可能错过好产品",
        probability: 1,
        value: 60,
      },
    ],
    correctChoice: 1,
    explanation: "理性评估是最佳的购物策略，既能享受优惠又能避免冲动消费",
    timeLimit: 30,
    difficulty: "easy",
  },
  {
    id: 28,
    type: "ethical",
    scenario: "社会责任：发现公司的不当行为",
    options: [
      { id: 0, description: "内部举报：通过公司渠道解决", value: 80 },
      { id: 1, description: "外部举报：寻求外部监督", value: 85 },
      { id: 2, description: "私下提醒：非正式沟通", value: 60 },
      { id: 3, description: "保持沉默：避免麻烦，但违背良心", value: 20 },
    ],
    correctChoice: 1,
    explanation: "外部举报是最有效的解决方式，能够确保问题得到公正处理",
    timeLimit: 55,
    difficulty: "hard",
  },
  {
    id: 29,
    type: "multi-criteria",
    scenario: "养老规划：50岁时的养老准备策略",
    options: [
      { id: 0, description: "增加储蓄：保守但收益有限", value: 70 },
      { id: 1, description: "多元投资：平衡风险和收益", value: 85 },
      { id: 2, description: "购买保险：转移风险，但成本较高", value: 75 },
      { id: 3, description: "依靠子女：传统但增加子女负担", value: 50 },
    ],
    correctChoice: 1,
    explanation: "多元投资是最佳的养老策略，能够在风险可控的前提下实现财富增值",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 30,
    type: "temporal",
    scenario: "技能提升：工作5年后的发展规划",
    options: [
      { id: 0, description: "深化专业：在现有领域深耕", value: 75 },
      { id: 1, description: "拓展技能：学习相关新技能", value: 85 },
      { id: 2, description: "转换跑道：完全改变职业方向", value: 65 },
      { id: 3, description: "维持现状：稳定但可能落后", value: 40 },
    ],
    correctChoice: 1,
    explanation:
      "拓展技能是最佳的职业发展策略，既能保持专业优势又能适应市场变化",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 31,
    type: "strategic",
    scenario: "数字化转型：传统企业的转型策略",
    options: [
      { id: 0, description: "全面数字化：激进转型，风险较高", value: 70 },
      { id: 1, description: "渐进式转型：稳步推进，平衡新旧", value: 85 },
      { id: 2, description: "外包合作：借助外力，但依赖性强", value: 75 },
      { id: 3, description: "观望等待：保守但可能落后", value: 40 },
    ],
    correctChoice: 1,
    explanation:
      "渐进式转型能够最大化成功概率，既能保持业务稳定又能实现数字化目标",
    timeLimit: 60,
    difficulty: "hard",
  },
  {
    id: 32,
    type: "probability",
    scenario: "国际扩张：选择进入新市场的策略",
    options: [
      {
        id: 0,
        description: "直接投资：控制力强，但风险高",
        probability: 0.6,
        value: 75,
      },
      {
        id: 1,
        description: "合资经营：分担风险，共享收益",
        probability: 0.8,
        value: 85,
      },
      {
        id: 2,
        description: "授权代理：成本低，但控制力弱",
        probability: 0.7,
        value: 70,
      },
      {
        id: 3,
        description: "出口贸易：风险最小，但收益有限",
        probability: 0.9,
        value: 60,
      },
    ],
    correctChoice: 1,
    explanation:
      "合资经营是进入新市场的最佳策略，能够有效分担风险并利用当地资源",
    timeLimit: 55,
    difficulty: "hard",
  },
  {
    id: 33,
    type: "risk",
    scenario: "资产配置：经济不确定期的投资策略",
    options: [
      { id: 0, description: "现金为王：流动性最强，但收益很低", value: 60 },
      { id: 1, description: "防御性投资：稳健资产，抗风险能力强", value: 85 },
      { id: 2, description: "机会主义：寻找低估资产", value: 75 },
      { id: 3, description: "高风险投资：博取高收益", value: 50 },
    ],
    correctChoice: 1,
    explanation:
      "防御性投资是经济不确定期的最佳策略，能够在保值的基础上获得适度收益",
    timeLimit: 50,
    difficulty: "hard",
  },
  {
    id: 34,
    type: "ethical",
    scenario: "AI伦理：如何平衡AI发展和伦理考量",
    options: [
      { id: 0, description: "快速发展：抢占先机，后续解决伦理问题", value: 60 },
      { id: 1, description: "伦理优先：建立框架，稳步发展", value: 85 },
      { id: 2, description: "国际合作：共同制定标准", value: 80 },
      { id: 3, description: "暂缓发展：等待伦理共识", value: 40 },
    ],
    correctChoice: 1,
    explanation:
      "伦理优先是AI发展的最佳方式，能够确保技术发展的可持续性和社会认同",
    timeLimit: 55,
    difficulty: "hard",
  },
  {
    id: 35,
    type: "multi-criteria",
    scenario: "全球供应链：后疫情时代的供应链策略",
    options: [
      { id: 0, description: "本土化：降低风险，但成本上升", value: 75 },
      { id: 1, description: "多元化：分散风险，提高韧性", value: 85 },
      { id: 2, description: "数字化：提高效率，增强透明度", value: 80 },
      { id: 3, description: "维持现状：成本最低，但风险集中", value: 50 },
    ],
    correctChoice: 1,
    explanation: "多元化供应链是最佳策略，能够在成本控制和风险管理之间取得平衡",
    timeLimit: 60,
    difficulty: "hard",
  },
  {
    id: 36,
    type: "temporal",
    scenario: "职业转换：35岁考虑重新开始",
    options: [
      { id: 0, description: "立即行动：年龄优势，但经验归零", value: 70 },
      { id: 1, description: "渐进转换：保持收入，逐步过渡", value: 85 },
      { id: 2, description: "深造准备：提升能力，降低风险", value: 80 },
      { id: 3, description: "放弃想法：现实考虑，维持稳定", value: 40 },
    ],
    correctChoice: 1,
    explanation:
      "渐进转换是最理智的职业转换策略，既能保证生活稳定又能实现职业目标",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 37,
    type: "strategic",
    scenario: "品牌建设：新品牌的市场定位策略",
    options: [
      { id: 0, description: "高端定位：利润丰厚，但市场有限", value: 70 },
      { id: 1, description: "大众市场：规模经济，但竞争激烈", value: 75 },
      { id: 2, description: "细分市场：精准定位，风险适中", value: 85 },
      { id: 3, description: "低价策略：快速占领，但利润微薄", value: 60 },
    ],
    correctChoice: 2,
    explanation: "细分市场定位是新品牌的最佳策略，能够在竞争中找到自己的立足点",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 38,
    type: "probability",
    scenario: "健康检查：发现轻微异常的处理方式",
    options: [
      {
        id: 0,
        description: "立即深度检查：彻底排查，但可能过度医疗",
        probability: 0.9,
        value: 80,
      },
      {
        id: 1,
        description: "定期观察：谨慎监控，平衡成本效益",
        probability: 0.85,
        value: 85,
      },
      {
        id: 2,
        description: "改善生活方式：自然调理",
        probability: 0.7,
        value: 75,
      },
      {
        id: 3,
        description: "忽略异常：节省费用，但可能延误",
        probability: 0.3,
        value: 30,
      },
    ],
    correctChoice: 1,
    explanation:
      "定期观察是最理性的健康管理方式，既能及时发现问题又能避免过度医疗",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 39,
    type: "risk",
    scenario: "创业融资：选择投资方的考虑",
    options: [
      { id: 0, description: "知名VC：品牌价值高，但条件苛刻", value: 75 },
      { id: 1, description: "战略投资者：资源丰富，协同效应强", value: 85 },
      { id: 2, description: "天使投资：条件宽松，但资金有限", value: 70 },
      { id: 3, description: "银行贷款：成本固定，但还款压力大", value: 60 },
    ],
    correctChoice: 1,
    explanation: "战略投资者能够提供资金以外的资源支持，是创业公司的最佳选择",
    timeLimit: 55,
    difficulty: "hard",
  },
  {
    id: 40,
    type: "ethical",
    scenario: "信息透明：如何平衡透明度和商业秘密",
    options: [
      { id: 0, description: "完全透明：建立信任，但可能泄露机密", value: 70 },
      { id: 1, description: "选择性透明：平衡利益，保护核心信息", value: 85 },
      { id: 2, description: "最低透明：法律要求，保护商业利益", value: 60 },
      { id: 3, description: "拒绝透明：保密至上，但影响信任", value: 40 },
    ],
    correctChoice: 1,
    explanation: "选择性透明是最佳的信息管理策略，既能建立信任又能保护商业利益",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 41,
    type: "multi-criteria",
    scenario: "团队招聘：选择新团队成员的标准",
    options: [
      {
        id: 0,
        description: "技能优先：专业能力强，但团队适应性未知",
        value: 75,
      },
      { id: 1, description: "综合评估：技能与文化适配并重", value: 85 },
      { id: 2, description: "文化匹配：团队和谐，但可能缺乏多样性", value: 70 },
      { id: 3, description: "成本考虑：经济实用，但质量可能不足", value: 50 },
    ],
    correctChoice: 1,
    explanation: "综合评估是最佳的招聘策略，既能保证专业能力又能维护团队文化",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 42,
    type: "temporal",
    scenario: "技术更新：软件系统的升级时机",
    options: [
      { id: 0, description: "立即升级：享受新功能，但可能有bug", value: 70 },
      { id: 1, description: "等待稳定版：安全可靠，错过早期优势", value: 85 },
      { id: 2, description: "分批升级：降低风险，但管理复杂", value: 80 },
      { id: 3, description: "延迟升级：稳定至上，但可能落后", value: 60 },
    ],
    correctChoice: 1,
    explanation: "等待稳定版是最理性的升级策略，能够平衡新功能和系统稳定性",
    timeLimit: 40,
    difficulty: "medium",
  },
  {
    id: 43,
    type: "probability",
    scenario: "投资时机：市场低迷时的投资决策",
    options: [
      {
        id: 0,
        description: "抄底投资：风险高，但收益可观",
        probability: 0.6,
        value: 75,
      },
      {
        id: 1,
        description: "定投策略：分散风险，平摊成本",
        probability: 0.8,
        value: 85,
      },
      { id: 2, description: "等待反弹：保守观望", probability: 0.7, value: 65 },
      {
        id: 3,
        description: "撤离市场：避免损失，但错过机会",
        probability: 0.9,
        value: 50,
      },
    ],
    correctChoice: 1,
    explanation: "定投策略是市场低迷时的最佳投资方式，能够有效降低时间风险",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 44,
    type: "strategic",
    scenario: "客户关系：处理重要客户的不合理要求",
    options: [
      { id: 0, description: "完全满足：维护关系，但可能开坏先例", value: 60 },
      { id: 1, description: "协商解决：寻求双赢方案", value: 85 },
      {
        id: 2,
        description: "坚持原则：维护公司利益，但可能失去客户",
        value: 70,
      },
      { id: 3, description: "转介其他：避免冲突，但可能丢失业务", value: 50 },
    ],
    correctChoice: 1,
    explanation:
      "协商解决是处理客户关系的最佳方式，既能维护关系又能保护公司利益",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 45,
    type: "risk",
    scenario: "新市场进入：评估进入壁垒和机会",
    options: [
      { id: 0, description: "强行进入：不惧壁垒，快速行动", value: 65 },
      { id: 1, description: "寻找切入点：巧妙进入，降低阻力", value: 85 },
      { id: 2, description: "合作进入：借助伙伴，分担风险", value: 80 },
      { id: 3, description: "放弃进入：避免风险，但错失机会", value: 40 },
    ],
    correctChoice: 1,
    explanation: "寻找切入点是最聪明的市场进入策略，能够以最小成本获得最大效果",
    timeLimit: 55,
    difficulty: "hard",
  },
  {
    id: 46,
    type: "ethical",
    scenario: "数据使用：客户数据的商业利用边界",
    options: [
      { id: 0, description: "最大化利用：充分挖掘数据价值", value: 50 },
      { id: 1, description: "征得同意：尊重用户意愿，合规使用", value: 85 },
      { id: 2, description: "最小化使用：保守使用，避免争议", value: 70 },
      { id: 3, description: "不使用数据：完全保护隐私，但放弃价值", value: 60 },
    ],
    correctChoice: 1,
    explanation: "征得同意是数据使用的最佳实践，既能创造价值又能保护用户权益",
    timeLimit: 50,
    difficulty: "medium",
  },
  {
    id: 47,
    type: "multi-criteria",
    scenario: "办公模式：后疫情时代的工作安排",
    options: [
      {
        id: 0,
        description: "全面返回办公室：加强协作，但缺乏灵活性",
        value: 70,
      },
      { id: 1, description: "混合办公模式：平衡效率和灵活性", value: 85 },
      { id: 2, description: "完全远程：最大灵活性，但协作困难", value: 65 },
      { id: 3, description: "因人而异：个性化安排，但管理复杂", value: 75 },
    ],
    correctChoice: 1,
    explanation:
      "混合办公模式是最佳的工作安排，既能保持团队协作又能提供工作灵活性",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 48,
    type: "temporal",
    scenario: "知识更新：专业知识的持续学习策略",
    options: [
      { id: 0, description: "密集学习：短期提升，但可能burnout", value: 70 },
      { id: 1, description: "持续学习：细水长流，效果持久", value: 85 },
      { id: 2, description: "按需学习：实用主义，但可能滞后", value: 75 },
      { id: 3, description: "停止学习：节省时间，但知识老化", value: 30 },
    ],
    correctChoice: 1,
    explanation: "持续学习是最佳的知识更新策略，能够保持专业竞争力和适应性",
    timeLimit: 40,
    difficulty: "easy",
  },
  {
    id: 49,
    type: "probability",
    scenario: "产品定价：新产品的价格策略",
    options: [
      {
        id: 0,
        description: "高价策略：建立高端形象，但市场有限",
        probability: 0.6,
        value: 70,
      },
      {
        id: 1,
        description: "渗透定价：快速获得市场份额",
        probability: 0.8,
        value: 85,
      },
      {
        id: 2,
        description: "跟随定价：安全稳妥，但缺乏差异化",
        probability: 0.7,
        value: 65,
      },
      {
        id: 3,
        description: "成本加成：简单直接，但可能缺乏竞争力",
        probability: 0.5,
        value: 55,
      },
    ],
    correctChoice: 1,
    explanation: "渗透定价是新产品的最佳策略，能够快速建立市场地位和用户基础",
    timeLimit: 45,
    difficulty: "medium",
  },
  {
    id: 50,
    type: "strategic",
    scenario: "危机预防：建立企业风险管理体系",
    options: [
      { id: 0, description: "全面防控：投入大量资源，但成本高昂", value: 75 },
      { id: 1, description: "重点防控：聚焦关键风险，效率最优", value: 85 },
      { id: 2, description: "保险转移：通过保险转移风险", value: 70 },
      { id: 3, description: "接受风险：节省成本，但承担后果", value: 40 },
    ],
    correctChoice: 1,
    explanation:
      "重点防控是最有效的风险管理策略，能够以最少资源获得最大保护效果",
    timeLimit: 55,
    difficulty: "hard",
  },
];
const TOTAL_DECISIONS = 10;

const stage = ref("instructions");
const currentDecisionIndex = ref(0);
const selectedDecisions = ref([]);
const responses = ref([]);
const reactionTimes = ref([]);
const timeLeft = ref(720);
const decisionTimeLeft = ref(0);
const startTime = ref(0);
const decisionStartTime = ref(0);
const score = ref(0);
const feedback = ref({
  show: false,
  correct: false,
  explanation: "",
  reactionTime: 0,
  selectedOption: "",
  correctOption: "",
});
const awaitingResponse = ref(true);
const showContinueButton = ref(false);
const finalResult = ref(null);

let timerInterval = null;

const { t } = useI18n();

const decision = computed(
  () => selectedDecisions.value[currentDecisionIndex.value]
);
const progress = computed(
  () => (currentDecisionIndex.value / TOTAL_DECISIONS) * 100
);

const decisionTypeName = computed(() => {
  if (!decision.value) return "";
  const names = {
    probability: t("decisionMakingTest.type.probability"),
    risk: t("decisionMakingTest.type.risk"),
    "multi-criteria": t("decisionMakingTest.type.multi-criteria"),
    temporal: t("decisionMakingTest.type.temporal"),
    ethical: t("decisionMakingTest.type.ethical"),
    strategic: t("decisionMakingTest.type.strategic"),
  };
  return names[decision.value.type] || "";
});

const decisionTypeBadgeClass = computed(() => {
  if (!decision.value) return "";
  const classes = {
    probability: "bg-blue-100 text-blue-700 border-blue-300",
    risk: "bg-red-100 text-red-700 border-red-300",
    "multi-criteria": "bg-green-100 text-green-700 border-green-300",
    temporal: "bg-orange-100 text-orange-700 border-orange-300",
    ethical: "bg-purple-100 text-purple-700 border-purple-300",
    strategic: "bg-indigo-100 text-indigo-700 border-indigo-300",
  };
  return classes[decision.value.type] || "";
});

const difficultyName = computed(() => {
  if (!decision.value) return "";
  const names = {
    easy: t("decisionMakingTest.difficulty.easy"),
    medium: t("decisionMakingTest.difficulty.medium"),
    hard: t("decisionMakingTest.difficulty.hard"),
  };
  return names[decision.value.difficulty] || "";
});

const difficultyBadgeClass = computed(() => {
  if (!decision.value) return "";
  const classes = {
    easy: "bg-green-100 text-green-700 border-green-300",
    medium: "bg-yellow-100 text-yellow-700 border-yellow-300",
    hard: "bg-red-100 text-red-700 border-red-300",
  };
  return classes[decision.value.difficulty] || "";
});

const setupNextQuestion = () => {
  const newDecision = selectedDecisions.value[currentDecisionIndex.value];
  if (newDecision) {
    decisionTimeLeft.value = newDecision.timeLimit;
    decisionStartTime.value = Date.now();
    awaitingResponse.value = true;
    showContinueButton.value = false;
  } else {
    calculateResults();
    stage.value = "results";
  }
};

const selectRandomDecisions = () => {
  const shuffled = [...DECISION_POOL].sort(() => Math.random() - 0.5);
  selectedDecisions.value = shuffled.slice(0, TOTAL_DECISIONS);
};

const handleStartTest = () => {
  selectRandomDecisions();
  score.value = 0;
  responses.value = [];
  reactionTimes.value = [];
  currentDecisionIndex.value = 0;
  timeLeft.value = 720;
  finalResult.value = null;

  stage.value = "test";
  startTime.value = Date.now();
  setupNextQuestion();
  startTimers();
};

const startTimers = () => {
  if (timerInterval) clearInterval(timerInterval);

  timerInterval = setInterval(() => {
    if (stage.value !== "test") {
      clearInterval(timerInterval);
      return;
    }

    if (decisionTimeLeft.value > 0) {
      decisionTimeLeft.value--;
    } else if (awaitingResponse.value) {
      handleDecisionSelect(0, true);
    }

    if (timeLeft.value > 0) {
      timeLeft.value--;
    } else {
      calculateResults();
      stage.value = "results";
      clearInterval(timerInterval);
    }
  }, 1000);
};

watch(stage, (newStage) => {
  if (newStage !== "test") {
    clearInterval(timerInterval);
  }
});

const handleDecisionSelect = (optionId, timeExpired = false) => {
  if (!awaitingResponse.value) return;

  const reactionTime = Date.now() - decisionStartTime.value;
  const currentDecision = decision.value;
  const isCorrect = optionId === currentDecision.correctChoice;

  awaitingResponse.value = false;
  responses.value.push(optionId);
  reactionTimes.value.push(reactionTime);

  let points = 0;
  if (isCorrect) {
    points += 100;
  } else {
    const selectedOption = currentDecision.options.find(
      (opt) => opt.id === optionId
    );
    points += selectedOption ? selectedOption.value : 0;
  }

  const timeTaken = currentDecision.timeLimit - decisionTimeLeft.value;
  if (timeTaken < currentDecision.timeLimit * 0.8 && !timeExpired) {
    points += Math.max(0, 30 - Math.floor(timeTaken / 5));
  }

  const difficultyMultiplier =
    currentDecision.difficulty === "hard"
      ? 1.2
      : currentDecision.difficulty === "medium"
      ? 1.1
      : 1.0;
  points = Math.round(points * difficultyMultiplier);

  if (
    ["multi-criteria", "strategic", "ethical"].includes(currentDecision.type)
  ) {
    points += 10;
  }

  score.value += points;

  const selectedOptionDesc =
    currentDecision.options.find((o) => o.id === optionId)?.description ||
    t("decisionMakingTest.noSelection");
  const correctOptionDesc =
    currentDecision.correctChoice !== undefined
      ? currentDecision.options[currentDecision.correctChoice].description
      : "";

  feedback.value = {
    show: true,
    correct: isCorrect,
    explanation: currentDecision.explanation || "",
    reactionTime,
    selectedOption: selectedOptionDesc,
    correctOption: correctOptionDesc,
  };

  showContinueButton.value = true;
};

const handleContinue = () => {
  feedback.value.show = false;
  showContinueButton.value = false;

  if (currentDecisionIndex.value < TOTAL_DECISIONS - 1) {
    currentDecisionIndex.value++;
    setupNextQuestion();
  } else {
    calculateResults();
    stage.value = "results";
  }
};

const calculateResults = () => {
  if (!selectedDecisions.value.length) {
    finalResult.value = { score: 0, details: {} };
    return;
  }

  const correctDecisions = responses.value.filter(
    (response, index) =>
      selectedDecisions.value[index] &&
      response === selectedDecisions.value[index].correctChoice
  ).length;

  const maxPossibleScore = selectedDecisions.value.reduce((sum, d) => {
    const difficultyMultiplier =
      d.difficulty === "hard" ? 1.2 : d.difficulty === "medium" ? 1.1 : 1.0;
    const baseScore = 130;
    const complexityBonus = ["multi-criteria", "strategic", "ethical"].includes(
      d.type
    )
      ? 10
      : 0;
    return (
      sum + Math.round((baseScore + complexityBonus) * difficultyMultiplier)
    );
  }, 0);

  const finalScore =
    maxPossibleScore > 0
      ? Math.min(100, Math.round((score.value / maxPossibleScore) * 100))
      : 0;
  const averageReactionTime =
    reactionTimes.value.length > 0
      ? Math.round(
          reactionTimes.value.reduce((sum, time) => sum + time, 0) /
            reactionTimes.value.length
        )
      : 0;

  const rtMean = averageReactionTime;
  const rtVariance =
    reactionTimes.value.length > 0
      ? reactionTimes.value.reduce(
          (sum, rt) => sum + Math.pow(rt - rtMean, 2),
          0
        ) / reactionTimes.value.length
      : 0;
  const consistencyIndex = Math.max(0, 100 - Math.sqrt(rtVariance) / 100);

  const typeGroups = {};
  selectedDecisions.value.forEach((d) => {
    if (!typeGroups[d.type]) typeGroups[d.type] = [];
    typeGroups[d.type].push(d);
  });

  const calculateTypeScore = (type) => {
    const typeDecisions = typeGroups[type] || [];
    if (typeDecisions.length === 0) return 0;
    const correctCount = responses.value.filter(
      (response, index) =>
        selectedDecisions.value[index]?.type === type &&
        response === selectedDecisions.value[index].correctChoice
    ).length;
    return Math.round((correctCount / typeDecisions.length) * 100);
  };

  finalResult.value = {
    id: Date.now().toString(),
    testType: "decision-making",
    score: finalScore,
    completedAt: new Date(),
    duration: Math.round((Date.now() - startTime.value) / 1000),
    details: {
      totalDecisions: selectedDecisions.value.length,
      correctDecisions,
      accuracy:
        selectedDecisions.value.length > 0
          ? Math.round(
              (correctDecisions / selectedDecisions.value.length) * 100
            )
          : 0,
      averageReactionTime,
      decisionQualityIndex:
        selectedDecisions.value.length > 0
          ? Math.round(score.value / selectedDecisions.value.length)
          : 0,
      totalScore: score.value,
      maxPossibleScore,
      consistencyIndex: Math.round(consistencyIndex),
      avgDecisionTime: Math.round(averageReactionTime / 100) / 10,
      difficultyDistribution: selectedDecisions.value.reduce((acc, d) => {
        acc[d.difficulty] = (acc[d.difficulty] || 0) + 1;
        return acc;
      }, {}),
      decisionTypes: Object.keys(typeGroups).map((type) => ({
        type,
        count: typeGroups[type].length,
        accuracy: calculateTypeScore(type),
      })),
    },
  };
};

onUnmounted(() => {
  if (timerInterval) {
    clearInterval(timerInterval);
  }
});
</script>

<style scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s ease;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.fade-slide-enter-active,
.fade-slide-leave-active {
  transition: all 0.4s ease;
}
.fade-slide-enter-from,
.fade-slide-leave-to {
  opacity: 0;
  transform: translateY(20px);
}

.fade-up-enter-active {
  transition: all 0.3s ease-out 0.2s; /* Add delay */
}
.fade-up-leave-active {
  transition: all 0.3s ease-in;
}
.fade-up-enter-from,
.fade-up-leave-to {
  transform: translateY(20px);
  opacity: 0;
}
</style>
